import Layout from "@/pages/Layout";
import Login from "@/pages/Login";
import { createBrowserRouter } from "react-router-dom";
import AuthRoute from "@/components/AuthRoute";
import { Suspense, lazy } from "react";
// import Home from "@/pages/Home";
// import Article from "@/pages/Article";
// import Publish from "@/pages/Publish";

// 路由懒加载
const Home = lazy(() => import("@/pages/Home"));
const Article = lazy(() => import("@/pages/Article"));
const Publish = lazy(() => import("@/pages/Publish"));

const router = createBrowserRouter([
    {
        path:'/',
        element:<AuthRoute><Layout/></AuthRoute>,
        children:[
            {
                index:true,
                element:<Suspense fallback={'Loading'}><Home></Home></Suspense>
            },
            {
                path:'article',
                element: <Suspense fallback={'Loading'}><Article></Article></Suspense>
            },
            {
                path:'publish',
                element: <Suspense fallback={'Loading'}><Publish></Publish></Suspense>
            }
        ]
    },
    {
        path:'/login',
        element:<Login></Login>
    }
])

export default router